<template>
	<view style="display: flex;flex-direction: column;background-color: #f3f7fe;padding: 30rpx;min-height: 100vh;">
		<view style="background-color: #fff;padding: 20rpx;border-radius: 20rpx">
			<view class="header"
				style="display: flex;justify-content: space-between;border-bottom: 1px solid #f3f7fe;padding-bottom: 30rpx;">
				<div style="display: flex;align-items: center;">
					<div
						style="background-color: rgb(85, 177, 249); padding: 3rpx; width: 70rpx; height: 70rpx; color: rgb(255, 255, 255); display: flex; justify-content: center; align-items: center; border-radius: 10rpx;">
						{{data.name}}
					</div>
					<div style="display: flex; flex-direction: column; justify-content: center; margin-left: 20rpx;">
						<span style="margin-bottom: 5px;">{{data.lastName}}</span>
						<span style="font-size: 12px;color: rgb(153, 153, 153);">{{data.departName}}</span>
					</div>
				</div>

				<div class="header-menu">
					<div class="mint-navbar">
						<a :class="type ==0?'mint-tab-item is-selected':'mint-tab-item'" @click="changeType(0)">
							<div class="mint-tab-item-label">日</div>
						</a>
						<a :class="type ==1?'mint-tab-item is-selected':'mint-tab-item'" @click="changeType(1)">
							<div class="mint-tab-item-label">周</div>
						</a>
						<a :class="type ==2?'mint-tab-item is-selected':'mint-tab-item'" @click="changeType(2)">
							<div class="mint-tab-item-label">月</div>
						</a>
					</div>
				</div>
			</view>

			<view class="calendar_container">
				<dayCalendar v-if="type == 0" :sundayIndex="6" mode="close" @change="change" />
				<monthCalendar v-if="type == 1" :sundayIndex="6" mode="close" @change="change" />
				<yearCalendar v-if="type == 2" :sundayIndex="6" mode="close" @change="change" />
			</view>
			<!-- 日统计 -->
			<view v-if="type == 0" class="data_person_day">
				<view class="tip">
					<span style="margin-bottom: 10rpx;">当日班次:{{data.data.serialInfo}}</span>

				</view>
				<view>
                    <van-empty v-if="Object.keys(data.data).length == 0 || data.data.signInfo.length == 0" description="暂无考勤数据" />
					<Timeline v-else title="打卡明细" :data-list="data.data.signInfo">
					</Timeline>
				</view>
			</view>
			<!-- 日统计 -->
			<!-- 周统计 -->
			<view v-if="type == 1" class="data_person_day">
				<van-grid :column-num="3" :border="false">
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>


				</van-grid>
			</view>
			<!-- 周统计 -->
			<!-- 周统计 -->
			<view v-if="type == 2" class="data_person_day">
				<van-grid :column-num="3" :border="false">
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>
					<van-grid-item>
						<span>0</span>
						<span style="margin-top: 30rpx; font-size: 12px; color: rgb(158, 165, 183);">打卡人数</span>
					</van-grid-item>


				</van-grid>
			</view>
			<!-- 周统计 -->
			<view style="font-size: 12px;color:#999 ;">统计结果至&nbsp;2023-02-27</view>
		</view>
	</view>
</template>

<script>
	import dayCalendar from '@/components/zsy-calendar/day-calendar'
	import monthCalendar from '@/components/zsy-calendar/month-calendar'
	import yearCalendar from '@/components/zsy-calendar/year-calendar'
	import Timeline from '@/components/Timeline'
	export default {
		components: {
			dayCalendar,
			monthCalendar,
			yearCalendar,
			Timeline
		},
		created() {
			if (this.$route.query.type !== undefined) {
				this.type = this.$route.query.type
			}
			this.init()
		},
		data() {
			return {
				type: 0,
				data: {
					lastName: '',
					departName: '',
					name: '',
					dataForDay: {
						 
					},
					dataForWeek: {
						 
					},
					dataForMonth: {
						 
					}
				}


			}
		},
		methods: {
			init() {
				uni.request({
					url: '/mobile/heo/AttendForPerson.jsp',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						startDate: this.$route.query.startDate,
						endDate: this.$route.query.endDate,
						lx: this.$route.query.lx,
						scope: this.$route.query.scope,
						userId: this.$route.query.userId,
					},
					success: (res) => {
						const result = res.data;
						if (result.ret === '0') {
							this.data = result.data
						} else {

						}

					}

				})

			},
			change(e) {
				console.log(e)
			},
			changeType(type) {
				this.type = type
			}
		}
	}
</script>

<style scoped>
	.mint-navbar {
		height: 0.5rem;
		display: flex;
		background-color: #9ea5b7;
		padding: 0.1rem;
		border-radius: 0.1rem;
		margin-top: 0.2rem;
	}

	.header-menu {
		display: flex;
		align-items: center;
	}

	.mint-navbar {
		height: 50rpx;
		display: flex;
		background-color: #9ea5b7;
		padding: 10rpx;
		border-radius: 10rpx;
	}

	.is-selected {
		background-color: #FFF;
		border-radius: 10rpx;
		font-weight: 600;
	}

	.mint-tab-item {
		flex: 1;
		color: #000;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 12px;
		width: 90rpx;
		cursor: pointer;
	}

	.data_person_day {
		min-height: 400rpx;
	}

	.tip {
		display: flex;
		flex-direction: column;
		font-size: 12px;
		color: #999;
	}
</style>
